﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace WinformPratice
{
    public partial class ImgUrl : Form
    {
        public ImgUrl()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String sHtmlText = richTextBox1.Text;


            Int16 i = 0;

            // 定义正则表达式用来匹配 img 标签
            //Regex regImg = new Regex(@"(http(.*).)", RegexOptions.IgnoreCase);
            Regex regImg = new Regex(@"(http.[^""<>]*(jpg|bmp|gif|png))", RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);

            // 搜索匹配的字符串
            MatchCollection matches = regImg.Matches(sHtmlText);
            richTextBox2.Text = "";
            // 取得匹配项列表
            foreach (Match match in matches)
            {
                i++;
               // richTextBox2.AppendText(i.ToString("000")+":\t"+match.Value + "\n");
                richTextBox2.AppendText(match.Value + "\n");
            }
           // return sUrlList;
        }
    }
}
